var t = getApp(), a = require("../../A4730AC3A71FB5DFC21562C4223CA4D1.js");

Page({
    data: {
        imgHeight: t.globalData.windowHeight - t.globalData.titleBarHeight - t.globalData.statusBarHeight,
        imgWidth: t.globalData.windowWidth,
        prizeList: [],
        btnUseText: {
            "00": "兑换",
            "01": "已兑换",
            "02": "已过期",
            10: "去使用",
            11: "已使用",
            12: "已过期"
        }
    },
    onReady: function() {
        var a = t.globalData.windowWidth, e = t.globalData.windowHeight - t.globalData.titleBarHeight - t.globalData.statusBarHeight, i = a, r = 2208 / 1242 * i;
        r < e && (i = 1242 * (r = e) / 2208), this.setData({
            imgHeight: r,
            imgWidth: i
        });
    },
    onShow: function() {
        this.getMyPrize();
    },
    usePrize: function(t) {
        var a = t.currentTarget.dataset.code || "", e = 1 * t.currentTarget.dataset.type, i = 1 * t.currentTarget.dataset.status, r = 1 * t.currentTarget.dataset.withCoupon;
        1 === e && 1 === i && 1 === r ? wx.switchTab({
            url: "/pages/index/index"
        }) : 0 === i && 0 === e && wx.navigateTo({
            url: "/pages/lottery/redeemPrize?code=" + a
        });
    },
    getMyPrize: function() {
        var t = this;
        wx.showLoading(), a.get("/v1/lottery/user/newPrize").then(function(a) {
            wx.hideLoading(), 1001 === a.data.code && t.setData({
                prizeList: a.data.response.data
            });
        }).catch(function() {
            wx.hideLoading();
        });
    }
});